package com.jiawa.train.batch.job;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.jiawa.train.batch.feigen.BusinessFeigen;
import jakarta.annotation.Resource;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import java.util.Date;

@DisallowConcurrentExecution
public class DailyTrainJob implements Job{
  private static  final Logger Log=  LoggerFactory.getLogger(DailyTrainJob.class);

  @Resource
  private BusinessFeigen businessFeigen;
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        MDC.put("LOG_ID", System.currentTimeMillis() + RandomUtil.randomString(3));
       Log.info("生成15天数据开始");
       //日期偏移15天
        Date date = new Date();
        DateTime dateTime = DateUtil.offsetDay(date, 15);
        Date date1 = dateTime.toJdkDate();
        businessFeigen.genDaily(date1);
        Log.info("生成15天数据结束");
    }
}
